package com.yidu.t299.dao.zzy;

import com.yidu.t299.domain.zzy.Class;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

@Mapper
public interface ClasssMapper {

    /**
     * 根据班级编号查询指定的信息
     * @param classId 班级编号
     * @return 班级对象
     */
    @Select({
        "select ",
        " class_id, class_name, class_type, startClass_time, startClass_num, classroom_id, ",
        " school_id, record_id, lesson_id",
        " from class",
        " where class_id = #{classId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="class_id", property="classId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="class_name", property="className", jdbcType=JdbcType.VARCHAR),
        @Result(column="class_type", property="classType", jdbcType=JdbcType.VARCHAR),
        @Result(column="startClass_time", property="startclassTime", jdbcType=JdbcType.VARCHAR),
        @Result(column="startClass_num", property="startclassNum", jdbcType=JdbcType.INTEGER),
        @Result(column="classroom_id", property="classroomId", jdbcType=JdbcType.INTEGER),
        @Result(column="school_id", property="schoolId", jdbcType=JdbcType.INTEGER),
        @Result(column="record_id", property="recordId", jdbcType=JdbcType.INTEGER),
        @Result(column="lesson_id", property="lessonId", jdbcType=JdbcType.INTEGER)
    })
    Class selectByPrimaryKey(Integer classId);

    /**
     * 得到所有校区信息
     * @return 校区对象集合
     */
    @Select("select * from class")
    @Results({
            @Result(id = true,column = "class_id",property = "classId"),
            @Result(column = "class_name",property = "className")
    })
    List<Class> selectAllGetClass();

    /**
     * 根据学员名称查询学员编号
     * @param classId 学员名称
     * @return 学员编号
     */
    @Select({
            "SELECT class_name" +
                    " FROM class" +
                    " WHERE class_id = #{classId}"
    })
    Integer selectByName(Integer classId);
}